/*
package com.test.springboot.servlet;

import com.test.springboot.domain.User;
import com.test.springboot.service.UserService;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "UserServlet",urlPatterns = "/common/login1")
public class UserServlet extends HttpServlet {
	
	@Resource
	private UserService userService;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// request.setCharacterEncoding("utf-8");
		String username=request.getParameter("username");
		String password=request.getParameter("password");
		
		System.out.println(username);
		
		User user = new User();
		user.setUsername(username);
		user.setPwd(password);
		
		User online = userService.login(user);
		
		if(online==null){//账号或者密码不正确 跳转到登录页面
			//重定向跳转
			//response.sendRedirect("/login.html");
			
			//转发跳转
			request.setAttribute("msg", "账号或者密码不正确");
		}
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=utf-8");
		
		request.getSession().setAttribute("user", online);
		response.sendRedirect("/admin/user.html");
	}
}
*/
